package com.example.designModel.strategy;

/**
 * 策略上下文配置
 */
public class CashContext {

    private CashSuper cs;

    public CashContext(String type) {
        switch (type)
        {
            case "正常收费":
                CashNormal cashNormal = new CashNormal();
                cs = cashNormal;
                break;
            case "满300返100":
                CashReturn cashReturn = new CashReturn("300", "100");
                cs = cashReturn;
                break;
            case "打8折":
                CashDisCount cashDisCount = new CashDisCount("0.8");
                cs = cashDisCount;
                break;
        }
    }

    public double GetResult(double money) {
        return cs.acceptCash(money);
    }
}
